package servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import DAO.ZCBS;

/**
 * Servlet implementation class addAssetBsServlet
 */
public class addAssetBsServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public addAssetBsServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		
	    request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		response.setContentType("text/plain");
		PrintWriter out = response.getWriter();
		
		String asset[] = new String[14];  //资产报损变量的数组

		/*
		 * 资产报损信息的参数
		 */
	    asset[0] = request.getParameter("AssetNo");
	    asset[1] = request.getParameter("Model");
	    asset[2] = request.getParameter("Department");
	    asset[3] = request.getParameter("LifeYears");
	    asset[4] = request.getParameter("Appraisaler");
	    asset[5] = request.getParameter("AppraisalTime");
	    asset[6] = request.getParameter("Name");
	    asset[7] = request.getParameter("Money");
	    asset[8] = request.getParameter("Principal");
	    asset[9] = request.getParameter("StartUseTime");
	    asset[10] = request.getParameter("NowStatus");
	    asset[11] = request.getParameter("DamageReason");
	    asset[12] = request.getParameter("Remark");
	    asset[13] = request.getParameter("AppraisalOpinion");	
		
	    /*
	     * 调用DAO里的addAssetBs函数，将相关资产信息写入数据库
	     * 数组参数asset
	     */	 
	    ZCBS zcbs = new ZCBS();
	    zcbs.addAssetBs(asset);
	    
		out.print("{success:true,msg:'保存成功'}");
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request,response);
	}

}
